<?php
include("../../include/connexion.php");


function run_query_consult($id){
$query = " SELECT		
        NOMEMP AS nom,
		PRENOMEMP AS prenom,
		DATENAISSANCE AS datenaiss,
		sexe,
		adresse,
		tel,
		mail,
		dateentree,
		NIVEAUETUDES AS niveau,
        nomservice,
        nomposte,
		typesituation
		FROM employe as E left join service as S on E.idservice=S.idservice
        left join poste as P on E.idposte=P.idposte
		left join situationfam as SF on E.idsituation=SF.idsituation
		WHERE IDEMP='$id';";

$rep = mysql_query($query);
$donnees = mysql_fetch_array($rep);
return $donnees;
}

function  run_query_comp($id){
$query = " SELECT
		typecomp
		FROM compemp as c
		LEFT JOIN competence as comp on c.idcomp=comp.idcomp
		WHERE IDEMP='$id'";

$rep = mysql_query($query);

$i=0;
$tab;
while ($donnees = mysql_fetch_array($rep)){
	$tab[$i]=$donnees['typecomp'];
	$i++;
}
return $tab;		
}

function insert_demande_conges($id){
$type=$_GET['type'];
$datedeb=date_mysql($_GET['date_debut']);
$datefin=date_mysql($_GET['date_fin']);
$nb_jours=nb_jours_ouvres(strtotime($datedeb), strtotime($datefin));


$query=" INSERT INTO conges(idemp, type, datedeb, datefin, nbjours, validechef, validerh) VALUES( '$id','$type', '$datedeb', '$datefin', '$nb_jours',2,2);";

mysql_query($query);

}

function run_query_conges($id){
$query = " SELECT type, datedeb, datefin, nbjours, validechef, validerh from conges where IDEMP= '$id' order by datedeb desc";

$rep = mysql_query($query);

$i=0;
$tab;
while ($donnees = mysql_fetch_array($rep)){
	$tab[$i]['type']=$donnees['type'];
	$tab[$i]['datedeb']=$donnees['datedeb'];
	$tab[$i]['datefin']=$donnees['datefin'];
	$tab[$i]['nbjours']=$donnees['nbjours'];
	$tab[$i]['validechef']=$donnees['validechef'];
	$tab[$i]['validerh']=$donnees['validerh'];
	$i++;
}
return $tab;
}


?>